home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / ui_connect.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  3.5 KB  |  125 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. #include "ui_local.h"
  4.  
  5. /*
  6. ===============================================================================
  7.  
  8. CONNECTION SCREEN
  9.  
  10. ===============================================================================
  11. */
  12.  
  13. qboolean    passwordNeeded = qtrue;
  14. menufield_s passwordField;
  15.  
  16. static connstate_t    lastConnState;
  17. static char            lastLoadingText[MAX_INFO_VALUE];
  18.  
  19. /*
  20. ========================
  21. UI_DrawConnectScreen
  22.  
  23. This will also be overlaid on the cgame info screen during loading
  24. to prevent it from blinking away too rapidly on local or lan games.
  25. ========================
  26. */
  27. void UI_DrawConnectScreen( qboolean overlay ) {
  28.     char            *s;
  29.     uiClientState_t    cstate;
  30.     char            info[MAX_INFO_VALUE];
  31.  
  32.     Menu_Cache();
  33.  
  34.     if ( !overlay ) {
  35.         // draw the dialog background
  36.         UI_SetColor( color_white );
  37.         UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );
  38.     }
  39.  
  40.     // see what information we should display
  41.     trap_GetClientState( &cstate );
  42.  
  43.     info[0] = '\0';
  44.     if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {
  45.         UI_DrawProportionalString( 320, 16, va( "Loading %s", Info_ValueForKey( info, "mapname" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, color_white );
  46.     }
  47.  
  48.     UI_DrawProportionalString( 320, 64, va("Connecting to %s", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
  49.     UI_DrawProportionalString( 320, 96, "Press Esc to abort", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
  50.  
  51.     // display global MOTD at bottom
  52.     UI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32, 
  53.         Info_ValueForKey( cstate.updateInfoString, "motd" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
  54.     
  55.     // print any server info (server full, bad version, etc)
  56.     if ( cstate.connState < CA_CONNECTED ) {
  57.         UI_DrawProportionalString( 320, 192, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
  58.     }
  59.  
  60. #if 0
  61.     // display password field
  62.     if ( passwordNeeded ) {
  63.         s_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128;
  64.         s_ingame_menu.nitems = 0;
  65.         s_ingame_menu.wrapAround = qtrue;
  66.  
  67.         passwordField.generic.type = MTYPE_FIELD;
  68.         passwordField.generic.name = "Password:";
  69.         passwordField.generic.callback = 0;
  70.         passwordField.generic.x        = 10;
  71.         passwordField.generic.y        = 180;
  72.         Field_Clear( &passwordField.field );
  73.         passwordField.width = 256;
  74.         passwordField.field.widthInChars = 16;
  75.         Q_strncpyz( passwordField.field.buffer, Cvar_VariableString("password"), 
  76.             sizeof(passwordField.field.buffer) );
  77.  
  78.         Menu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action );
  79.  
  80.         MField_Draw( &passwordField );
  81.     }
  82. #endif
  83.  
  84.     if ( lastConnState > cstate.connState ) {
  85.         lastLoadingText[0] = '\0';
  86.     }
  87.     lastConnState = cstate.connState;
  88.  
  89.     switch ( cstate.connState ) {
  90.     case CA_CONNECTING:
  91.         s = va("Awaiting challenge...%i", cstate.connectPacketCount);
  92.         break;
  93.     case CA_CHALLENGING:
  94.         s = va("Awaiting connection...%i", cstate.connectPacketCount);
  95.         break;
  96.     case CA_CONNECTED:
  97.         s = "Awaiting gamestate...";
  98.         break;
  99.     case CA_LOADING:
  100.         return;
  101.     case CA_PRIMED:
  102.         return;
  103.     default:
  104.         return;
  105.     }
  106.  
  107.     UI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, color_white );
  108.  
  109.  
  110.     // password required / connection rejected information goes here
  111. }
  112.  
  113.  
  114. /*
  115. ===================
  116. UI_KeyConnect
  117. ===================
  118. */
  119. void UI_KeyConnect( int key ) {
  120.     if ( key == K_ESCAPE ) {
  121.         trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
  122.         return;
  123.     }
  124. }
  125.